<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib  prefix = "fn" uri = "http://java.sun.com/jsp/jstl/functions"%>
<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<sec:authentication property="principal" var="currentPrincipal" scope="page" />

<div class="modal-dialog x-modal-dialog" style="width:600px; margin-top: 150px;">

  <div class="modal-content">

    <div class="modal-header x-breadcrumb clearfix">

      <h2><i class="glyphicon glyphicon-fire" title=""></i>&nbsp;&nbsp;<span>修改教练可预约日期</span></h2>

      <button type="button" class="close" data-dismiss="modal">&times;</button>

    </div>

    <form class="form-horizontal" method="POST" action="${ctx.host}/principals/${relation.coach.id}/edit-appoint-days/${relation.manager.id}" data-validate="true">
      
      <input type="hidden" name="_method" value="PATCH" >
      <input type="hidden" name="orginalAppointDays" value="${relation.appointDays}" >
      
      <div class="modal-body">
        <div class="form-group">
          <label class="control-label col-xs-4">店长：</label>
          <div class="col-xs-6 pull-left"><p class="form-control-static">${relation.manager.name}</p></div>
        </div>
        <div class="form-group appointOption">
          <label class="control-label col-xs-4">可预约日期：</label>
          <div class="col-xs-6 pull-left">
            <select name="appointOption"  class="form-control" data-validate="required">
              <option></option>
              <option value="all"${empty relation.appointDays ? ' selected' : ''}>周一至周日</option>
              <option value="appoint"${not empty relation.appointDays ? ' selected' : ''}>指定日期</option>
            </select>
          </div>
        </div>

         <div class="form-group appointHours">
          <label class="control-label col-xs-4">可预约时间：</label>
          <div class="col-xs-6 pull-left">
            <select name="appointHours"  class="form-control select2" multiple>
              <option></option>
              <c:forEach var="time" items="${allAppointTime}">
                <option value="${time}" ${selectAppointHour.contains(time) ? ' selected' : '' }>${time}</option>
              </c:forEach>
            </select>
          </div>
        </div>
      </div>
      
      <c:if test="${not empty relation.appointDays}">
        <div class="form-group appoint">
          <label class="control-label col-xs-4">指定日期：</label>
           <div class="col-xs-6 pull-left">
             <select name="appointDays" multiple class="form-control" data-validate="required">
               <option></option>
               <option value="1"${fn:contains(relation.appointDays, '1,') ? ' selected' : ''}>周一</option>
               <option value="2"${fn:contains(relation.appointDays, '2,') ? ' selected' : ''}>周二</option>
               <option value="3"${fn:contains(relation.appointDays, '3,') ? ' selected' : ''}>周三</option>
               <option value="4"${fn:contains(relation.appointDays, '4,') ? ' selected' : ''}>周四</option>
               <option value="5"${fn:contains(relation.appointDays, '5,') ? ' selected' : ''}>周五</option>
               <option value="6"${fn:contains(relation.appointDays, '6,') ? ' selected' : ''}>周六</option>
               <option value="7"${fn:contains(relation.appointDays, '7,') ? ' selected' : ''}>周日</option>
             </select>
           </div>
         </div>
      </c:if>
      
      <div class="modal-footer clearfix">
        <button type="submit" class="btn btn-success btn-shadow btn-shadow-success x-btn">确定</button>&nbsp;&nbsp;&nbsp;&nbsp;
        <button type="button" class="btn btn-default btn-shadow btn-shadow-default x-btn" data-dismiss="modal">取消</button>
      </div>
    </form>
  </div>
</div>

<script type="text/javascript">
  $(function() {

    $('.select2').select2({
      placeholder : '请选择',
      minimumResultsForSearch : -1,
      allowClear : true,
      width : '100%'
    });
  })
</script>